﻿<center>
<form method="POST" action="index.php/?content=add" enctype="multipart/form-data">
<small>
Название
</small>
<input type=text" width="20" name="Name" class="input"> 
<br>
<small>IMG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</small>
<input type="file" name="filename" class="input">
<br>
<small>
Тема&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</small>
<select name="Theme" class="input">
<option value="Programming">Програмирование</option>
<option value="Hard">Железо</option>
<option value="Soft">Софтины</option>
<option value="Mobile">Мобильные</option>
<option value="Other">Другое</option>
</select>
<br><br>
<TEXTAREA name="Text" cols="50" rows="30">
</TEXTAREA>
<br>
<div id="captcha" >
<small>
Введите это:
</small>
  <img src = "engine/captcha.php"/>
 <br>
  <small>Сюда:</small> <input type = "text" name = "kapcha" class="captcha"/>
</div>
 <br>
  <br>

<input type="submit" value="Запостить" name="Message" class="input">
</center>
<?php
if(isset($_POST['Name']))
{
if($_SESSION['rand_code'] != $_POST['kapcha'])
{
exit;
}
if(isset($_FILES["filename"]["tmp_name"]))
{
if($_FILES["filename"]["size"] > 1024*3*1024)
{
exit;
}
if(is_uploaded_file($_FILES["filename"]["tmp_name"]))
{
$randname = base64_encode(rand(1,10000));
move_uploaded_file($_FILES["filename"]["tmp_name"], "files/uploaded/img/".$randname.$_FILES["filename"]["name"]);
} 
else 
{
exit;
}
TA($_POST['Text'],$_POST['Theme'],$_POST['Name'],$randname.$_FILES["filename"]["name"]);
//проверка капчи

}
else
{
echo "Файл не прекреплен.";
}
}
?>